package com.qianbei.user.feedback;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;

import com.android.volley.Request.Method;
import com.qianbei.R;
import com.qianbei.common.base.BaseActivity;
import com.qianbei.common.init.SetData;
import com.qianbei.common.net.control.ServerResult;
import com.qianbei.common.net.view.MsgAlert;
import com.qianbei.common.utilis.IDCard;

public class FeedBackActivity extends BaseActivity {

	EditText id1, id2;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.feedbace_activity);
		setTitle("用户反馈");
	}

	@Override
	public void initView() {
		id1 = (EditText) findViewById(R.id.id1);
		id2 = (EditText) findViewById(R.id.id2);
	}

	@Override
	public void initClick() {
		findViewById(R.id.addcomment_submit).setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		super.onClick(v);
		switch (v.getId()) {
		case R.id.addcomment_submit:
			String content = id1.getText().toString().trim();
			String contacts = id2.getText().toString().trim();
			
			if (TextUtils.isEmpty(content)) {
				new MsgAlert().show("请输入反馈信息");
				return;
			}
			
			if (TextUtils.isEmpty(contacts)) {
				new MsgAlert().show("请输入联系方式");
				return;
			}
			
			if (!IDCard.isMobileNO(contacts)) {
				new MsgAlert().show(getString(R.string.menu_login_activity_check_mobile_length1));
				return;
			}
			
			feedBack(SetData.getUserID(),content,contacts);
			break;

		default:
			break;
		}
	}

	/**
	 * @error_info
	 * @contact
	 */
	private void feedBack(String uid,String content, String mobile) {
		initServer(Method.POST,FEEDBACK, "uid", uid,
				"mobile", mobile, "content", content);
	}

	@Override
	public void serverFinish(ServerResult sr) {
		super.serverFinish(sr);
		if (sr.isContinue) {
			new MsgAlert().show("上传成功");
			finish();
		}
	}
}
